home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / scripts / starscape-logo.scm.z / starscape-logo.scm
Encoding:
GIMP Script-Fu Script  |  1999-07-21  |  4.5 KB  |  119 lines

  1. ;  Nova Starscape
  2. ;  Create a text effect that simulates an eerie alien glow around text
  3.  
  4. (define (find-blend-coords w h)
  5.   (let* ((denom (+ (/ w h) (/ h w)))
  6.      (bx    (/ (* -2 h) denom))
  7.      (by    (/ (* -2 w) denom)))
  8.     (cons bx by)))
  9.  
  10. (define (find-nova-x-coord drawable x1 x2 y)
  11.   (let* ((x 0)
  12.      (alpha 3)
  13.      (range (- x2 x1))
  14.      (min-clearance 5)
  15.      (val '())
  16.      (val-left '())
  17.      (val-right '())
  18.      (val-top '())
  19.      (val-bottom '())
  20.      (limit 100)
  21.      (clearance 0))
  22.     (while (and (= clearance 0) (> limit 0))
  23.        (set! x (+ (rand range) x1))
  24.        (set! val (cadr (gimp-drawable-get-pixel drawable x y)))
  25.        (set! val-left (cadr (gimp-drawable-get-pixel drawable (- x min-clearance) y)))
  26.        (set! val-right (cadr (gimp-drawable-get-pixel drawable (+ x min-clearance) y)))
  27.        (set! val-top (cadr (gimp-drawable-get-pixel drawable x (- y min-clearance))))
  28.        (set! val-bottom (cadr (gimp-drawable-get-pixel drawable x (+ y min-clearance))))
  29.        (if (and (= (aref val alpha) 0) (= (aref val-left alpha) 0) (= (aref val-right alpha) 0)
  30.             (= (aref val-top alpha) 0) (= (aref val-bottom alpha) 0))
  31.            (set! clearance 1) (set! limit (- limit 1))))
  32.     x))
  33.  
  34. (define (script-fu-starscape-logo text size font glow-color)
  35.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  36.      (border (/ size 4))
  37.      (grow (/ size 30))
  38.      (offx (* size 0.03))
  39.      (offy (* size 0.02))
  40.      (feather (/ size 4))
  41.      (shadow-feather (/ size 25))
  42.      (text-layer (car (gimp-text img -1 0 0 text border TRUE size PIXELS "*" font "*" "*" "*" "*")))
  43.      (width (car (gimp-drawable-width text-layer)))
  44.      (height (car (gimp-drawable-height text-layer)))
  45.      (w (* (/ (- width (* border 2)) 2.0) 0.75))
  46.      (h (* (/ (- height (* border 2)) 2.0) 0.75))
  47.      (novay (* height 0.3))
  48.      (novax (find-nova-x-coord text-layer (* width 0.2) (* width 0.8) novay))
  49.      (novaradius (/ (min height width) 7.0))
  50.      (cx (/ width 2.0))
  51.      (cy (/ height 2.0))
  52.      (bx (+ cx (car (find-blend-coords w h))))
  53.      (by (+ cy (cdr (find-blend-coords w h))))
  54.      (bg-layer (car (gimp-layer-new img width height RGB_IMAGE "Background" 100 NORMAL)))
  55.      (glow-layer (car (gimp-layer-new img width height RGBA_IMAGE "Glow" 100 NORMAL)))
  56.      (shadow-layer (car (gimp-layer-new img width height RGBA_IMAGE "Drop Shadow" 100 NORMAL)))
  57.      (bump-channel (car (gimp-channel-new img width height "Bump Map" 50 '(0 0 0))))
  58.      (old-pattern (car (gimp-patterns-get-pattern)))
  59.      (old-fg (car (gimp-palette-get-foreground)))
  60.      (old-bg (car (gimp-palette-get-background))))
  61.     (gimp-image-disable-undo img)
  62.     (gimp-image-resize img width height 0 0)
  63.     (gimp-image-add-layer img bg-layer 1)
  64.     (gimp-image-add-layer img glow-layer 1)
  65.     (gimp-image-add-layer img shadow-layer 1)
  66.     (gimp-layer-set-preserve-trans text-layer TRUE)
  67.  
  68.     (gimp-palette-set-background '(0 0 0))
  69.     (gimp-edit-fill img bg-layer)
  70.     (gimp-edit-clear img shadow-layer)
  71.     (gimp-edit-clear img glow-layer)
  72.  
  73.     (gimp-selection-layer-alpha img text-layer)
  74.     (gimp-selection-grow img grow)
  75.     (gimp-selection-feather img feather)
  76.     (gimp-palette-set-background glow-color)
  77.     (gimp-selection-feather img feather)
  78.     (gimp-edit-fill img glow-layer)
  79.  
  80.     (gimp-selection-layer-alpha img text-layer)
  81.     (gimp-selection-feather img shadow-feather)
  82.     (gimp-palette-set-background '(0 0 0))
  83.     (gimp-selection-translate img offx offy)
  84.     (gimp-edit-fill img shadow-layer)
  85.  
  86.     (gimp-selection-none img)
  87.     (gimp-palette-set-background '(31 31 31))
  88.     (gimp-palette-set-foreground '(255 255 255))
  89.     (gimp-blend img text-layer FG-BG-RGB NORMAL BILINEAR 100 0 REPEAT-NONE FALSE 0 0 cx cy bx by)
  90.  
  91.     (plug-in-nova 1 img glow-layer novax novay glow-color novaradius 100)
  92.  
  93.     (gimp-selection-all img)
  94.     (gimp-patterns-set-pattern "Stone")
  95.     (gimp-bucket-fill img bump-channel PATTERN-BUCKET-FILL NORMAL 100 0 FALSE 0 0)
  96.     (plug-in-bump-map 1 img text-layer bump-channel 135.0 45.0 4 0 0 0 0 FALSE FALSE 0)
  97.     (gimp-image-remove-channel img bump-channel)
  98.     (gimp-selection-none img)
  99.  
  100.     (gimp-layer-set-name text-layer text)
  101.     (gimp-patterns-set-pattern old-pattern)
  102.     (gimp-palette-set-background old-bg)
  103.     (gimp-palette-set-foreground old-fg)
  104.     (gimp-image-enable-undo img)
  105.     (gimp-display-new img)))
  106.  
  107.  
  108. (script-fu-register "script-fu-starscape-logo"
  109.             "<Toolbox>/Xtns/Script-Fu/Logos/Starscape"
  110.             "Starscape using the Nova plug-in"
  111.             "Spencer Kimball"
  112.             "Spencer Kimball"
  113.             "1997"
  114.             ""
  115.             SF-VALUE "Text String" "\"Nova\""
  116.             SF-VALUE "Font Size (in pixels)" "150"
  117.             SF-VALUE "Font" "\"engraver\""
  118.             SF-COLOR "Glow Color" '(28 65 188))
  119.